package cn.com.headfree.salary.service.impl;

import cn.com.headfree.entity.TEmpBaseInfo;
import cn.com.headfree.entity.TEmployeeMobility;
import cn.com.headfree.entity.TSeniorCompetent;
import cn.com.headfree.salary.service.ExportWordUserDataInfoService;
import cn.com.headfree.salary.service.IUserDataInfoService;
import cn.com.headfree.vo.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("exportWordUserDataInfoService")
public class ExportWordUserDataInfoServiceImpl implements ExportWordUserDataInfoService {

	private static final Logger LOG = LogManager.getLogger(ExportWordUserDataInfoServiceImpl.class);

	@Autowired
	private IUserDataInfoService userDataInfoService;


	@Override
	public SalaryVo getModelData(String erpNo, String salaryId,int year) {
		//基本信息
		TEmpBaseInfo tEmpBaseInfo = userDataInfoService.getBaseInfoByErpNo(erpNo);
		//上一年度取得学历
		List<EducateInfoVo> educateInfos = userDataInfoService.getEducateInfoByErpNo(erpNo,salaryId,year);
		//上年度专业技术资格
		List<ProTecInfoVo> proTecInfos = userDataInfoService.getProTecInfoByErpNo(erpNo,salaryId,year);
		//上年度技能等级
		List<SkillLevelInfoVo> skillLevelInfos = userDataInfoService.getSkillLevelInfoByErpNo(erpNo,salaryId,year);
		//上年度专家人才称号
		List<ExpertTitleVo> expertTitleInfos = userDataInfoService.getExpertTitleInfoByErpNo(erpNo,salaryId,year);
		//上年度学术成果
		List<AcadeAchiveVo> acadeAchiveVos = userDataInfoService.getAcadeAchiveInfoByErpNo(erpNo,salaryId,year);
		//上年度发明专利
		List<PatentInfoVo> patentInfos = userDataInfoService.getPatentInfoByErpNo(erpNo,salaryId,year);
		//上年度科技管理创新
		List<TecManInnovVo> tecManInnovVos = userDataInfoService.getTecManInnovByErpNo(erpNo,salaryId,year);
		//上年度技艺革新
		List<TecInnovInfoVo> tecInnovVos = userDataInfoService.getTecInnovInfoByErpNo(erpNo,salaryId,year);
		//上年度专业竞赛考试
		List<ContestInfoVo> tContestInfos = userDataInfoService.getContestInfoByErpNo(erpNo,salaryId,year);
		//上年度个人荣誉
		List<HonorDatasVo> honorDatasVos = userDataInfoService.getHonnorInfoByErpNo(erpNo,salaryId,year);
		//上一年度绩效
		List<YearEffectVo> yearEffectVos = userDataInfoService.getYearEffectByErpNo(erpNo,year);
		//当前工作经历--职务职级
		List<WorkExpInfoVo> workExpInfoVos = userDataInfoService.getWorkExpInfoByErpNo(erpNo,salaryId);
		//全日制学历信息
		List<EducateInfoVo> fullTimeEdus = userDataInfoService.getFullTimeEducateInfoByErpNo(erpNo);
		//最高学历信息
		List<EducateInfoVo> highEdus = userDataInfoService.getEducateInfoHighEducByErpNo(erpNo);
		//全部专业技术资格
		List<ProTecInfoVo> proTecInfoVoList = userDataInfoService.getAllProTecInfoByErpNo(erpNo,salaryId);
		//全部技能等级
		List<SkillLevelInfoVo> skillLevelInfoVoList = userDataInfoService.getAllSkillLevelInfoByErpNo(erpNo,salaryId);
		//全部专家人才称号
		List<ExpertTitleVo> expertTitleInfoVoList = userDataInfoService.getAllExpertTitleInfoByErpNo(erpNo,salaryId);
		//上一年员工流动
		//全部专家人才称号
//		List<TEmployeeMobility> employeemobilities = userDataInfoService.getAllEmployeeMobilitiesInfoByErpNo(erpNo,salaryId);
		//拼装数据
		SalaryVo salaryVo = new SalaryVo();
		LOG.info("===============组装模板数据开始=================");
		salaryVo.settEmpBaseInfo(tEmpBaseInfo);
		if(educateInfos != null && educateInfos.size() >0){
			salaryVo.setEducateInfoVos(educateInfos);
		}
		if(proTecInfos != null && proTecInfos.size() >0){
			salaryVo.setProTecInfoVos(proTecInfos);
		}
		if(skillLevelInfos != null && skillLevelInfos.size() >0){
			salaryVo.setSkillLevelInfoVos(skillLevelInfos);
		}
		if(expertTitleInfos != null && expertTitleInfos.size() >0){
			salaryVo.setExpertTitleVos(expertTitleInfos);
		}
		if(acadeAchiveVos != null && acadeAchiveVos.size() >0){
			salaryVo.setAcadeAchiveVos(acadeAchiveVos);
		}
		
		if(acadeAchiveVos != null && acadeAchiveVos.size() >0){
			salaryVo.setAcadeAchiveVos(acadeAchiveVos);
		}
		if(patentInfos != null && patentInfos.size() >0){
			salaryVo.setPatentInfoVos(patentInfos);
		}
		if(tecManInnovVos != null && tecManInnovVos.size() >0){
			salaryVo.setTecManInnovVos(tecManInnovVos);
		}
		if(tecInnovVos != null && tecInnovVos.size() >0){
			salaryVo.setTecInnovInfoVos(tecInnovVos);
		}
		if(tContestInfos != null && tContestInfos.size() >0){
			salaryVo.setContestInfoVos(tContestInfos);
		}
		if(honorDatasVos != null && honorDatasVos.size() >0){
			salaryVo.setHonorDatasVos(honorDatasVos);
		}
		if(yearEffectVos != null && yearEffectVos.size() > 0){
			salaryVo.setYearEffectVo(yearEffectVos.get(0));
		}
		if(workExpInfoVos != null && workExpInfoVos.size() > 0){
			salaryVo.setWorkExpInfoVo(workExpInfoVos.get(0));
		}
		if(fullTimeEdus != null && fullTimeEdus.size() > 0){
			salaryVo.setFullTimeEduInfo(fullTimeEdus.get(0));
		}
		if(highEdus != null && highEdus.size() > 0){
			salaryVo.setHighEduInfo(highEdus.get(0));
		}
		if(proTecInfoVoList != null && proTecInfoVoList.size() > 0){
			salaryVo.setProTecInfoVo(proTecInfoVoList.get(0));
		}
		if(skillLevelInfoVoList != null && skillLevelInfoVoList.size() > 0){
			salaryVo.setSkillLevelInfoVo(skillLevelInfoVoList.get(0));
		}
		if(expertTitleInfoVoList != null && expertTitleInfoVoList.size() > 0){
			salaryVo.setExpertTitleVo(expertTitleInfoVoList.get(0));
		}
		LOG.info("======================数据组装完成========================");
		return salaryVo;
	}


}
